package de.iritgo.skillfull.component;

import java.util.List;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;

import de.iritgo.skillfull.component.visitor.Visitor;
import de.iritgo.skillfull.entity.Entity;
import de.iritgo.skillfull.entity.EntityImpl;

/**
 * The base component interface
 * 
 * @author held
 *
 */
public interface Component
{
	/**
	 * Return the id of the component. The id is the base identifier for a type of component
	 * 
	 * @return The id
	 */
	public String getId ();

	/**
	 * Return the unique name of the component.
	 * 
	 * @return The name of the component
	 */
	public String getName ();

	/**
	 * Describe the component
	 * 
	 * @return The description
	 */
	public String getDescription ();

	/**
	 * Init the component for reuse...
	 */
	public void init ();
	
	/**
	 * Check if the component has a child with the given id
	 * 
	 * @param id The id of the component
	 * @return True if exists
	 */
	public boolean hasComponent (String id);

	/**
	 * Get all child components
	 * 
	 * @return The components
	 */
	public List<Component> getComponents ();
	
	/**
	 * Get a child component by the given id
	 * 
	 * @param id The id of the component
	 * @return The component
	 */
	public Component getComponentById (String id);

	/**
	 * Iterate the vistor to the complete component tree
	 * 
	 * @param visitor The visitor
	 */
	public void accept (Visitor visitor);
	
	/**
	 * Set the entity to the component
	 * 
	 * @param entity The entity
	 */
	public void setEntity (Entity entity);
	
	/**
	 * Get the entity in the component
	 * 
	 * @return The entity
	 */
	public Entity getEntity ();

	/**
	 * Render all components
	 * 
	 * @param container The container
	 * @param g The graphics
	 * @param entity The entity
	 */
	public void render (GameContainer container, Graphics g, Entity entity);

	/**
	 * Update all components
	 * 
	 * @param container The container
	 * @param delta The delta
	 * @param entity The entity
	 */
	public void update (GameContainer container, int delta, Entity entity);

	/**
	 * If the component active than set it to true
	 * 
	 * @param active The active flag
	 */
	public void setActive (boolean active);
	
	/**
	 * Deactivate a component. For example the collision component is deactivated after the call
	 */
	public void deactivate ();

	/**
	 * The component/entity is removed from the entity manager. Work in this method on an reuse...
	 * 
	 * @param entity The entity
	 */
	public void removed (Entity entity);
	
	/**
	 * Print the component configuration
	 */
	public void printConfiguration ();
}
